package com.bjpowernode.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.bjpowernode.common.constant.Constant;
import com.bjpowernode.entity.TActivityRemark;
import com.bjpowernode.mapper.TActivityRemarkMapper;
import com.bjpowernode.entity.query.ActivityRemarkQuery;
import com.bjpowernode.service.ActiveRemarkService;
import com.bjpowernode.util.LoginInfoUtil;
import com.bjpowernode.entity.vo.ActivityRemarkListVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
@RequiredArgsConstructor
public class ActiveRemarkServiceImpl implements ActiveRemarkService {

    private final TActivityRemarkMapper activityRemarkMapper;

    @Override
    public int activityRemark(ActivityRemarkQuery activityRemarkQuery) {
        TActivityRemark activityRemark = new TActivityRemark();
        BeanUtil.copyProperties(activityRemarkQuery, activityRemark);
        activityRemark.setCreateTime(new Date());
        activityRemark.setCreateBy(LoginInfoUtil.getCurrentLoginUser().getId());
        return activityRemarkMapper.insert(activityRemark);
    }

    @Override
    public PageInfo<ActivityRemarkListVO> activityRemarks(Integer current, Integer id) {
        PageHelper.startPage(current, Constant.PAGE_SIZE);
        List<ActivityRemarkListVO> list = activityRemarkMapper.getActivityRemarkByPage(current,id);
        PageInfo<ActivityRemarkListVO> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }


}
